package com.eedi.framework.tenant.dal.mapper;

import com.eedi.framework.common.enums.CommonStatusEnum;
import com.eedi.framework.mybatis.core.mapper.BaseMapperX;
import com.eedi.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupBottomReq;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupBottomResp;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupBottomUpReq;
import com.eedi.framework.tenant.convert.SysSetupBottomConvert;
import com.eedi.framework.tenant.dal.dataobject.SysSetupBottomDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 系统设置
 * 底部设置
 *
 * @author zybourn
 */
@Mapper
public interface SysSetupBottomMapper extends BaseMapperX<SysSetupBottomDO> {

    default void insert(SysSetupBottomReq req) {
        SysSetupBottomDO sysSetupBottomDO = SysSetupBottomConvert.INSTANCE.convert(req);
        sysSetupBottomDO.setSysSetupBottomStatus(CommonStatusEnum.ENABLE);
        insert(sysSetupBottomDO);
    }

    default void update(SysSetupBottomUpReq req) {
        SysSetupBottomDO sysSetupBottomDO = SysSetupBottomConvert.INSTANCE.convert(req);
        updateById(sysSetupBottomDO);
    }

    default void upStatus(String sysSetupBottomId, CommonStatusEnum status) {
        SysSetupBottomDO sysSetupBottomDO = new SysSetupBottomDO();
        sysSetupBottomDO.setSysSetupBottomId(sysSetupBottomId)
                .setSysSetupBottomStatus(status);
        updateById(sysSetupBottomDO);
    }

    default SysSetupBottomResp getById(String sysSetupBottomId) {
        return SysSetupBottomConvert.INSTANCE.convert(selectById(sysSetupBottomId));
    }


    default List<SysSetupBottomResp> getList() {

        return SysSetupBottomConvert.INSTANCE.convert(selectList(new LambdaQueryWrapperX<>()));
    }
}
